<%@ page language="java" contentType="text/html; charset=utf-8"   pageEncoding="utf-8"%>
<%@taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>系列、品名列表 </title>
<script type="text/javascript">
function checkAll(form, checked){
    for (var i=0; i<form.elements.length; i++) {
        var e = form.elements[i];
        if (e.type=="checkbox"){
			if(e.checked != checked){
				e.click();
			}
			// e.checked = checked;
		}
    }
}

function deleteAll(form){
	var idStr = "";
	for (var i=0; i<form.elements.length; i++) {
        var e = form.elements[i];
        if (e.type=="checkbox" && e.name == 'checkOne'){
			if(e.checked){
				idStr += e.value + ',';
			}			
		}
    }
    
    if(idStr == ""){
    	alert("请选择要删除的项！");
    	return false;
    }
    
   if(confirm("确认删除选中项？")){
    	window.document.location = "${pageContext.request.contextPath}/admin/series-list!delete.do?value=" + idStr;
    }
    
}

function deleteOne(idStr){
	if(confirm("确认删除该项？")){
    	window.document.location = "${pageContext.request.contextPath}/admin/series-list!delete.do?value=" + idStr;
    }
}
</script>
</head>
<body>
<s:form id="form1" action="series-list!list.do" theme="simple" method="post">
<table border="0" width="100%">
	<tr>
		<td width="100%" align="center">
			系列、品名列表
			<s:actionmessage/>
		</td>
	</tr>
</table>
<table width="100%">
	<tr>
		<td colspan="9">
			类型：<s:select label="类型"
					name="flag"
					headerKey="-1" headerValue="请选择类型"
					list="#{'1':'系列', '2':'品名'}"
					required="false"/>
			&nbsp;&nbsp;&nbsp;&nbsp;
			<input type="submit" value="提 交">
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			<input type="button" value="删除选中项" onclick="deleteAll(this.form);"/>
		</td>
	</tr>
</table>
<table border="1" width="100%">
	<tr>
		<td width="3px" align="center">
			<input type="checkbox" id="allbox" name="allbox" onclick="checkAll(this.form,this.checked)"/>
			<!-- <label for="allbox" style="cursor:pointer">全选</label> -->
		</td>
		<td width="60%">名称</td>		
		<td width="20%">类型</td>
		<td>操作</td>
	</tr>
	<s:iterator value="seriesList">
		<tr>
			<td align="center" width="3px" ><input type="checkbox" name="checkOne" value="<s:property value='id'/>"></td>
			<td><s:property value="value"/></td>
			<td>
				<s:if test="%{flag eq 1}">系列</s:if>
				<s:if test="%{flag == 2}">品名</s:if>
			</td>
			<td><a href="series-input!input.do?id=<s:property value='id'/>">修改</a>&nbsp;&nbsp;&nbsp;<a href="#" onclick="deleteOne('<s:property value="id"/>')">删除</a></td>
		</tr>
		</s:iterator>
</table>
</s:form>
</body>
</html>